<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
<style type="text/css">
.ftitle{
    font-size:14px;
    font-weight:bold;
    padding:5px 0;
    margin-bottom:10px;
    border-bottom:1px solid #ccc;
}
.fitem{
    margin-bottom:10px;
}
.fitem label{
    display:inline-block;
    font-weight:bold;
    text-align:center;
    width: 29%;
}
</style>
</head>
<body style="padding: 5px">
<form id="form1" method="post">
	<div class="fitem">
		<label>产&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;品：</label>
		<input id="input0298" class="mini-combobox" url="performance_medicine_sort.do" multiSelect="false"  valueFromSelect="true" style="width:220px;" required="true"
			        name="medicineId" textField="name" valueField="id" allowInput="false" onbeforenodeselect="vacation" popupWidth="200px;"/>
	</div>
	<div class="fitem">
		<label>数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量：</label>
		<input name="number" class="mini-textbox" vtype="float" required="true" maxLength="9" style="width: 220px"/>
	</div>
	<div class="fitem">
		<label>提成金额：</label>
		<input name="money" class="mini-textbox" vtype="float" required="true" maxLength="9" style="width: 220px"/>
	</div>
	<input name="id" class="mini-hidden" />
	<input name="deptType" class="mini-hidden" />
	<input name="isLeader" class="mini-hidden" />
</form>
<div style="text-align:center;padding-top: 45px;">
    <a class="mini-button" onclick="ok();" style="width:60px;margin-right:20px;">确定</a>       
    <a class="mini-button" onclick="window.CloseOwnerWindow();" style="width:60px;">取消</a>       
</div>
<script type="text/javascript">
mini.parse();
var oldMedicineId = '';
var form = new mini.Form("form1");
function saveData() {
	var o = form.getData();
    form.validate();
    if (form.isValid() == false) return;
	var medicineId = mini.get("input0298").getValue();
	if(oldMedicineId == medicineId) {
		save(o);
	} else {
		$.post("salary_include_medicine.do", {medicineId: medicineId}, function(data) {
	    	if(data.success) {
				save(o);
	    	} else {
				mini.alert('数据重复'); return;
			}
		}, "json");
	}
}

function vacation(e) {
	if('2c9081594830779a01483099bebb0002' == e.node.id) {
		mini.alert('不能选择根类别,请重新选择');
		return;
	}	
}

//标准方法接口定义
function SetData(data) {
	//跨页面传递的数据对象，克隆后才可以安全使用
    data = mini.clone(data);
	oldMedicineId = data.medicineId;
    form.setData(data);
}

function ok() {
	saveData();
}

function save(o) {
	$.post("performance_salary_save_edit.do",o,function(text) {
    	if(text.success){
        	window.CloseOwnerWindow("succ");
        }else{
        	mini.alert("数据错误！");
        }
    },"json");
}
</script>
</body>
</html>